<?php
/**
 * The template for displaying Home pages.
 *
 * @package Sento
 */

get_header(); ?>
<div class="row">
<?php 
$count = 0;
//获取分类
$categories = get_categories(
			array(
					"hide_empty" => true,
					"exclude" => array(1)
				)
		);
	foreach ($categories as $category) {
		query_posts(
				array(
						"cat"=>$category->term_id,
						"posts_per_page"=>5
				));
		if( have_posts() ){
?>
	<div class="col-xs-12">
		<div class="panel panel-default">
	      <div class="panel-body">
	        <h3 class="panel-title" style="display: inline-block; border: 1px #999 solid; padding: 3px; min-width: 120px; text-align: center;">
	        	<a href="<?php echo get_category_link($category->term_id)?>"><?php echo $category->name; ?></a>
	        </h3>
	      </div>
	      <div class="panel-body">

			<?php
				//查询未分类的

 				$wp_query->is_home=true;
			?>
			<?php if( have_posts() ): ?>

				<div id="container-<?php echo $category->term_id;?>" class="portfolio-wrapper">

				<?php 
				$index = 0;
				while( have_posts() ): the_post(); $count=$count+1; $index=$index+1;
					if($index == 1){
				?>

					<div class="blog-grid element<?php echo thinkup_input_stylelayout(); ?>">

					<article id="post-<?php the_ID(); ?>" <?php post_class('blog-article'); ?>>

						<header class="entry-header<?php thinkup_input_stylelayout_class1(); ?>">

							<?php echo thinkup_input_blogimage(); ?>

						</header>

						<div class="entry-content<?php thinkup_input_stylelayout_class2(); ?><?php thinkup_input_blogcommentclass(); ?>">

							<?php thinkup_input_blogtitle(); ?>
							<?php thinkup_input_blogmeta(); ?>
							<?php thinkup_input_blogtext(); ?>

						</div><div class="clearboth"></div>

					</article><!-- #post-<?php get_the_ID(); ?> -->

					</div>
				<?php 
					}
					else{
				?>
					<div class="blog-grid element<?php echo thinkup_input_stylelayout(); ?>">

					<article id="post-<?php the_ID(); ?>" <?php post_class('blog-article'); ?>>

						<div class="entry-content<?php thinkup_input_stylelayout_class2(); ?><?php thinkup_input_blogcommentclass(); ?>">
							<?php thinkup_input_blogtitle(); ?>
							<?php thinkup_input_blogfulldate(); ?>
						</div><div class="clearboth"></div>

					</article><!-- #post-<?php get_the_ID(); ?> -->

					</div>
					
				<?php }?>
				<?php endwhile; ?>

				</div><div class="clearboth"></div>

			<?php else: ?>

			<?php ;?>

			<?php endif; wp_reset_query(); ?>
	      </div>
	    </div>
	</div>
<?php 
		}	
	}?>

<?php 
	if($count == 0){
		get_template_part( 'no-results', 'archive' );
	}
?>
</div>
<?php get_footer() ?>